﻿Imports System.Data.SqlClient

Public Class clsCargosFonacot
    Private mintIdCargoFonacot As Integer
    Private mintIdEmpleado As Integer
    Private mdblMonto As Double
    Private mintMes As Integer
    Private mintAnio As Integer
    Private mdatFecha As Date
    Public Property IdCargoFonacot() As Integer
        Get
            Return mintIdCargoFonacot
        End Get
        Set(ByVal value As Integer)
            mintIdCargoFonacot = value
        End Set
    End Property
    Public Property IdEmpleado() As Integer
        Get
            Return mintIdEmpleado
        End Get
        Set(ByVal value As Integer)
            mintIdEmpleado = value
        End Set
    End Property
    Public Property Monto() As Double
        Get
            Return mdblMonto
        End Get
        Set(ByVal value As Double)
            mdblMonto = value
        End Set
    End Property
    Public Property Mes() As Integer
        Get
            Return mintMes
        End Get
        Set(ByVal value As Integer)
            mintMes = value
        End Set
    End Property
    Public Property Anio() As Integer
        Get
            Return mintAnio
        End Get
        Set(ByVal value As Integer)
            mintAnio = value
        End Set
    End Property
    Public Property Fecha As Date
        Get
            Return mdatFecha
        End Get
        Set(value As Date)
            mdatFecha = value
        End Set
    End Property
    Public Sub New()
        mintIdCargoFonacot = 0
        mintIdEmpleado = 0
        mdblMonto = 0
        mintMes = 0
        mintAnio = 0
        mdatFecha = Now()
    End Sub
    Public Sub Borrar()
        Call SetSqlCitra("Delete From CargosFonacot Where IdCargoFonacot = " & IdCargoFonacot)
    End Sub
    Public Sub Insertar()
        Dim sql As String = "Insert Into CargosFonacot (" & _
                            "IdCargoFonacot," & _
                            "IdEmpleado," & _
                            "Monto," & _
                            "Mes," & _
                            "Anio," & _
                            "Fecha)" & _
                            "VALUES (" & _
                            "@IdCargoFonacot," & _
                            "@IdEmpleado," & _
                            "@Monto," & _
                            "@Mes," & _
                            "@Anio," & _
                            "@Fecha)"


        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        Dim Command As New SqlCommand(sql, cnConn)

        Command.Parameters.AddWithValue("IdCargoFonacot", IdCargoFonacot)
        Command.Parameters.AddWithValue("IdEmpleado", mintIdEmpleado)
        Command.Parameters.AddWithValue("Monto", mdblMonto)
        Command.Parameters.AddWithValue("Mes", Mes)
        Command.Parameters.AddWithValue("Anio", mintAnio)
        Command.Parameters.AddWithValue("Fecha", mdatFecha)

        cnConn.Open()
        Dim RowsAffected As Integer = Command.ExecuteNonQuery

        If RowsAffected > 0 Then
            cnConn.Close()
        Else
            MsgBox("No fue posible insertar el mes " & mintMes, MsgBoxStyle.Exclamation, "Aviso")
            If cnConn.State = ConnectionState.Open Then
                cnConn.Close()
            End If
        End If
    End Sub
End Class
